from PIL import Image
img = Image.open("curb.jpg")
pixels = img.load()
w, h = img.size
for x in range(w):
    for y in range(h):
        r, g, b = pixels[x, y]
        k = (r+g+b)/3
        if r > k * 1.1:
            pixels[x, y] = int(k), int(k), int(k)
img.show()
img.save("curb_out.jpg", "JPEG")